////////////////////////////////////////
//	File Header
//	Author: Stephen Ringer | stephen.ringer@gmail.com
//	File: SAGAInputDevice.h
//
////////////////////////////////////////
#pragma once
////////////////////////////////////////
//	File Includes
#include <windows.h>
#include <stdio.h>
#include "../SAGAD3D/SAGA.h"
//
////////////////////////////////////////

////////////////////////////////////////
//	Class Name: SAGAInputDevice
class SAGAInputDevice 
{
protected:
	HWND       m_hWndMain;          // application main window
	HINSTANCE  m_hDLL;              // dll module handle
	bool       m_bRunning;          // after succesful initialization
	FILE      *m_pLog;              // log file
  
  
public:
	SAGAInputDevice(void) {};
	virtual ~SAGAInputDevice() {};


	// INIT/RELEASE STUFF:
	// ===================

	virtual HRESULT Init(HWND, const RECT*, bool)=0;

	// release API specific stuff
	virtual void Release()=0;

	// is initialized?
	virtual bool IsRunning()=0;

	// joystick available?
	virtual bool HasJoystick(char *pJoyName)=0;

	// poll input devices
	virtual HRESULT Update()=0;

	// will work for mouse and joystick only
	virtual HRESULT GetPosition(SAGAINPUTDEV, POINT*)=0;

	// for joysticks only (intensity range from -1 to +1)
	virtual HRESULT GetJoyDeflection(float*, float*)=0;

	// get change in mouse position
	virtual POINT GetMouseDelta()=0;

	// will work for keyboard, mouse and joystick
	virtual bool IsPressed(SAGAINPUTDEV, UINT)=0;

	// will work for keyboard, mouse and joystick
	virtual bool IsReleased(SAGAINPUTDEV, UINT)=0;

};
typedef class SAGAInputDevice *LPSAGAINPUTDEVICE;
//
////////////////////////////////////////

////////////////////////////////////////
//	External Functions
//		Pulled from DLL
extern "C" 
{
	HRESULT CreateInputDevice(HINSTANCE hDLL, SAGAInputDevice **pInterface);
	typedef HRESULT (*CREATEINPUTDEVICE)(HINSTANCE hDLL, SAGAInputDevice **pInterface);

	HRESULT ReleaseInputDevice(SAGAInputDevice **pInterface);
	typedef HRESULT (*RELEASEINPUTDEVICE)(SAGAInputDevice **pInterface);
}
//
////////////////////////////////////////

////////////////////////////////////////
// keyboard scan codes from dinput.h
#define SVK_ESCAPE          0x01
#define SVK_TAB             0x0F
#define SVK_SPACE           0x39
#define SVK_RETURN          0x1C
#define SVK_BACK            0x0E
#define SVK_CAPITAL         0x3A
#define SVK_MINUS           0x0C
#define SVK_EQUALS          0x0D
#define SVK_LBRACKET        0x1A
#define SVK_RBRACKET        0x1B
#define SVK_SEMICOLON       0x27
#define SVK_APOSTROPHE      0x28
#define SVK_GRAVE           0x29
#define SVK_BACKSLASH       0x2B
#define SVK_COMMA           0x33
#define SVK_PERIOD          0x34
#define SVK_SLASH           0x35
// CHARACTER KEYS
#define SVK_A               0x1E
#define SVK_S               0x1F
#define SVK_D               0x20
#define SVK_F               0x21
#define SVK_G               0x22
#define SVK_H               0x23
#define SVK_J               0x24
#define SVK_K               0x25
#define SVK_L               0x26
#define SVK_Z               0x2C
#define SVK_X               0x2D
#define SVK_C               0x2E
#define SVK_V               0x2F
#define SVK_B               0x30
#define SVK_N               0x31
#define SVK_M               0x32
#define SVK_Q               0x10
#define SVK_W               0x11
#define SVK_E               0x12
#define SVK_R               0x13
#define SVK_T               0x14
#define SVK_Y               0x15
#define SVK_U               0x16
#define SVK_I               0x17
#define SVK_O               0x18
#define SVK_P               0x19
// MAIN NUM KEYS
#define SVK_1               0x02
#define SVK_2               0x03
#define SVK_3               0x04
#define SVK_4               0x05
#define SVK_5               0x06
#define SVK_6               0x07
#define SVK_7               0x08
#define SVK_8               0x09
#define SVK_9               0x0A
#define SVK_0               0x0B
// FUNCTION KEYS
#define SVK_F1              0x3B
#define SVK_F2              0x3C
#define SVK_F3              0x3D
#define SVK_F4              0x3E
#define SVK_F5              0x3F
#define SVK_F6              0x40
#define SVK_F7              0x41
#define SVK_F8              0x42
#define SVK_F9              0x43
#define SVK_F10             0x44
#define SVK_F11             0x57
#define SVK_F12             0x58
// ON NUMPAD
#define SVK_NPPLUS          0x4E
#define SVK_NPMINUS         0x4A
#define SVK_NPDECIMAL       0x53
#define SVK_NPCOMMA         0xB3
#define SVK_NPDIVIDE        0xB5
#define SVK_NPMULTIPLY      0x37
#define SVK_NPENTER         0x9C
#define SVK_NUMLOCK         0x45
#define SVK_NP1             0x4F
#define SVK_NP2             0x50
#define SVK_NP3             0x51
#define SVK_NP4             0x4B
#define SVK_NP5             0x4C
#define SVK_NP6             0x4D
#define SVK_NP7             0x47
#define SVK_NP8             0x48
#define SVK_NP9             0x49
#define SVK_NP0             0x52
// CTRL, ALT, SHFT and WINDWS
#define SVK_RSHIFT          0x36
#define SVK_LSHIFT          0x2A
#define SVK_RCTRL           0x9D
#define SVK_LCTRL           0x1D
#define SVK_RALT            0xB8
#define SVK_LALT            0x38
#define SVK_LWIN            0xDB
#define SVK_RWIN            0xDC
// ON ARROW KEYPAD
#define SVK_UP              0xC8
#define SVK_DOWN            0xD0
#define SVK_LEFT            0xCB
#define SVK_RIGHT           0xCD
#define SVK_INSERT          0xD2
#define SVK_DELETE          0xD3
#define SVK_HOME            0xC7
#define SVK_END             0xCF
#define SVK_PGDOWN          0xD1
#define SVK_PGUP            0xC9
#define SVK_PAUSE           0xC5    /* Pause */
#define SVK_SCROLL          0x46    /* Scroll Lock */
//
////////////////////////////////////////